<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog
        :close-on-click-modal="false"
        :before-close="crud.cancelCU"
        :visible.sync="crud.status.cu > 0"
        :title="crud.status.title"
        width="700px"
      >
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          size="medium "
          label-width="120px"
        >
          <el-form-item label="标题">
            <el-input v-model="form.title" style="width: 370px" />
          </el-form-item>
<!--          <el-form-item label="公司ID">-->
<!--            <el-input v-model="form.companyId" style="width: 370px" />-->
<!--          </el-form-item>-->

          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="全局信息内容" name="first">
              <el-form-item label="全局信息内容">
                <quill-editor
                  ref="myQuillEditor"
                  v-model="form.globalContent"
                  class="editor"
                  style="width: 500px"
                  :options="editorOption"
                  @blur="onEditorBlur($event)"
                  @focus="onEditorFocus($event)"
                  @change="onEditorChange($event)"
                />
              </el-form-item>
            </el-tab-pane>
            <el-tab-pane label="项目区位富文本" name="second">
              <el-form-item label="项目区位富文本">
                <quill-editor
                  ref="myQuillEditor"
                  v-model="form.locationContent"
                  class="editor"
                  style="width: 500px"
                  :options="editorOption"
                  @blur="onEditorBlur($event)"
                  @focus="onEditorFocus($event)"
                  @change="onEditorChange($event)"
                />
              </el-form-item>
            </el-tab-pane>
            <el-tab-pane label="户型鉴赏富文本" name="third">
              <el-form-item label="户型鉴赏富文本">
                <quill-editor
                  ref="myQuillEditor"
                  v-model="form.layoutContent"
                  class="editor"
                  style="width: 500px"
                  :options="editorOption"
                  @blur="onEditorBlur($event)"
                  @focus="onEditorFocus($event)"
                  @change="onEditorChange($event)"
                />
              </el-form-item>
            </el-tab-pane>
            <el-tab-pane label="全景信息内容" name="fourth">
              <el-form-item label="全景信息内容">
                <quill-editor
                  ref="myQuillEditor"
                  v-model="form.panoramaContent"
                  class="editor"
                  style="width: 500px"
                  :options="editorOption"
                  @blur="onEditorBlur($event)"
                  @focus="onEditorFocus($event)"
                  @change="onEditorChange($event)"
                />
              </el-form-item>
            </el-tab-pane>
            <el-tab-pane label="样板间内容" name="fifth">
              <el-form-item label="样板间内容">
                <quill-editor
                  ref="myQuillEditor"
                  v-model="form.exampleContent"
                  class="editor"
                  style="width: 500px"
                  :options="editorOption"
                  @blur="onEditorBlur($event)"
                  @focus="onEditorFocus($event)"
                  @change="onEditorChange($event)"
                />
              </el-form-item>
            </el-tab-pane>
            <el-tab-pane label="园林漫步内容" name="sixth">
              <el-form-item label="园林漫步内容">
                <quill-editor
                  ref="myQuillEditor"
                  v-model="form.roamContent"
                  class="editor"
                  style="width: 500px"
                  :options="editorOption"
                  @blur="onEditorBlur($event)"
                  @focus="onEditorFocus($event)"
                  @change="onEditorChange($event)"
                />
              </el-form-item>
            </el-tab-pane>
          </el-tabs>

          <!-- <el-form-item label="更新时间">
            <el-input v-model="form.updateTime" style="width: 370px" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createTime" style="width: 370px" />
          </el-form-item> -->
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button
            :loading="crud.status.cu === 2"
            type="primary"
            @click="crud.submitCU"
            >确认</el-button
          >
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
        style="width: 100%"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="title" label="标题" />
<!--        <el-table-column prop="companyId" label="公司ID" />-->
        <el-table-column prop="globalContent" label="全局信息内容" />
        <el-table-column prop="locationContent" label="项目区位富文本" />
        <el-table-column prop="layoutContent" label="户型鉴赏富文本" />
        <el-table-column prop="panoramaContent" label="全景信息内容" />
        <el-table-column prop="exampleContent" label="样板间内容" />
        <el-table-column prop="roamContent" label="园林漫步内容" />
        <el-table-column prop="updateTime" label="更新时间" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column
          v-if="checkPer(['admin', 'houseShow:edit', 'houseShow:del'])"
          label="操作"
          width="150px"
          align="center"
        >
          <template slot-scope="scope">
            <udOperation :data="scope.row" :permission="permission" />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudHouseShow from "@/api/houseShow/houseShow";
import CRUD, { presenter, header, form, crud } from "@crud/crud";
import rrOperation from "@crud/RR.operation";
import crudOperation from "@crud/CRUD.operation";
import udOperation from "@crud/UD.operation";
import pagination from "@crud/Pagination";

const defaultForm = {
  houseShowId: null,
  title: null,
  companyId: null,
  globalContent: null,
  locationContent: null,
  layoutContent: null,
  panoramaContent: null,
  exampleContent: null,
  roamContent: null,
  updateTime: null,
  createTime: null,
};
export default {
  name: "HouseShow",
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: "房屋展示",
      url: "api/houseShow",
      idField: "houseShowId",
      sort: "houseShowId,desc",
      crudMethod: { ...crudHouseShow },
    });
  },
  data() {
    return {
      activeName: "first",
      permission: {
        add: ["admin", "houseShow:add"],
        edit: ["admin", "houseShow:edit"],
        del: ["admin", "houseShow:del"],
      },
      rules: {
        houseShowId: [{ required: true, message: "不能为空", trigger: "blur" }],
      },
      editorOption: {},
    };
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true;
    },
  },
};
</script>

<style scoped>
</style>
